﻿import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.VirtualKeyboard 2.1


Window {
    width: screenWidth
    height: screenHeight
    visible: true    
    // visibility:"Windowed"   // 全屏显示应用程序
    visibility:"FullScreen"   // 全屏显示应用程序
    title: qsTr("数控双头锯")

    flags:Qt.WindowFullscreenButtonHint |  Qt.Window    // 无边框

    // 显示到副屏
    // x: Qt.application.screens[1].virtualX
    // y: Qt.application.screens[1].virtualY

    // 界面边框属性
    property real screenWidth: Screen.width
    property real screenHeight: Screen.height


    // 弹窗属性
    property bool zeroLocationFailed: Cpp_Connect.ZeroLocationFailed           // 位置清零失败
    property bool servoReady: Cpp_Connect.ServoReady                 // 伺服未准备好
    property bool readLocationFailed: Cpp_Connect.ReadLocationFailed                   // 读取位置失败
    property bool readLocationOver: Cpp_Connect.ReadLocationOver                     // 读取位置完成
    property bool forbidRun_NotFindZero: Cpp_Connect.ForbidRun_NotFindZero                // 未找零禁止移动
    property bool forbidLeftRun: Cpp_Connect.ForbidLeftRun                        // 禁止左行
    property bool forbidRightRun: Cpp_Connect.ForbidRightRun                       // 禁止右行
    property bool currentLocationEqualLocation: Cpp_Connect.CurrentLocationEqualLocation         // 当前位置等于定位位置
    property bool notChooseMechine: Cpp_Connect.NotChooseMechine                     // 未选择电机
    property bool workingForbidImpact: Cpp_Connect.WorkingForbidImpact                  // 工作中禁止压紧

    property bool sawErrForbidImpact: Cpp_Connect.SawErrForbidImpact            // 锯片错误禁止压紧提示
    property bool currentSectionesWorked: Cpp_Connect.CurrentSectionesWorked    // 当前段数已加工完成
    property bool sawNotRunForbidOut: Cpp_Connect.SawNotRunForbidOut            // 锯片未启动禁止出锯提示
    property bool notImpactForbidOut: Cpp_Connect.NotImpactForbidOut            // 未压紧禁止出锯提示
    property bool currentLocationForbidOut: Cpp_Connect.CurrentLocationForbidOut    // 当前位置禁止出锯提示
    property bool autoPrintRun: Cpp_Connect.AutoPrintRun                        // 自动打印中继
    property bool setExtraShortLessCDLC: Cpp_Connect.SetExtraShortLessCDLC      // 设定超短小于超短料长提示
    property bool sawInPlacesSignalErr: Cpp_Connect.SawInPlacesSignalErr        // 锯片到位信号异常提示
    property bool locationZeroOver: Cpp_Connect.LocationZeroOver                // 定位清零完成提示
    property bool forbidRightMechineMove: Cpp_Connect.ForbidRightMechineMove    // 禁止右机头移动提示
    property bool extraLongLocation: Cpp_Connect.ExtraLongLocation              // 超长定位提示

    property bool changeSawMethod: Cpp_Connect.ChangeSawMethod                  // 切换锯方式提示
    property bool errCorrected: Cpp_Connect.ErrCorrected                        // 错误修正完成提示
    property bool forbid_45NB: Cpp_Connect.Forbid_45NB                          // 禁止45度内摆提示
    property bool extraShortOrigin: Cpp_Connect.ExtraShortOrigin                // 超短复位提示
    property bool cleanBatteryWarning: Cpp_Connect.CleanBatteryWarning          // 清除电池报警提示
    property bool cleanBatteryDone: Cpp_Connect.CleanBatteryDone                // 清除电池报警完成
    property bool q_TL_Err: Cpp_Connect.Q_TL_Err                                // 前托料异常提示
    property bool z_TL_Err: Cpp_Connect.Z_TL_Err                                // 中托料异常提示
    property bool h_TL_Err: Cpp_Connect.H_TL_Err                                // 后托料异常提示


    Item{
        id:backGround
        anchors.fill: parent
    }

    TopShowArea{
        id:topShowArea
        visible: !loginWindow.visible
    }

    LoginWindow{        // 登录界面
        id:loginWindow
        visible: true
        // visible: false
    }

    ConnectSettingWindows{      // 连接参数设定界面
        id:connectSettingWindow
        anchors.centerIn: parent
        // visible: true
        visible: false
    }

    ProcessWindow{      // 加工界面
        id:processWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    LS_LocationWindow{      // 拉手定位界面
        id:ls_LocationWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    LG_ChooseWindow{        // 料高选择界面
        id:lg_ChooseWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }    

    ExtraLongProcessWindow{     // 超长加工界面
        id:extraLongProcessWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    ExtraShortProcessWindow{        // 超短加工界面
        id:extraShortProcessWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    PL_ProcessWindow{       // 排料加工界面
        id:pl_ProcessWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    NetWorkFormulaWindow{         // 网络料单界面
        id:netWorkFormulaWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    QRCodeFormulaWindow{        // 二维码料单界面
        id:qrCodeFormulaWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    JM_ProcessWindow{       // 角码加工界面
        id:jm_ProcessWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    ManagerSettingWindow{       // 管理界面
        id:managerSettingWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    IO_MonitorWindow{       // IO监控界面
        id:io_MonitorWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    PrinterSettingWindow{           // 打印机设置界面
        id:printerSettingWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }    

    AdvanceSettingsWindow{          // 高级设置界面(输入密码进入  默认账号 admin  默认密码:123)
        id:advanceSettingWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    ServoParameterSetting{          // 伺服参数设置界面
        id:servoParameterSetting
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    MaterialRackParameter{          // 托料参数设置界面
        id:materialRackParameter
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    LocationCompensateSetting{          // 位置补偿设置界面
        id:locationCompensateSetting
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    AnyLocationCompensate{          // 任意位置补偿界面
        id:anyLocationCompensate
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    ChangePasswdWindow{             // 修改密码界面
        id:changePasswdWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    DeviceLayoutWindow{         // 设备配置界面
        id:deviceLayoutWindow
        anchors.top: backGround.top
        anchors.topMargin: 155
        anchors.horizontalCenter: backGround.horizontalCenter
        // visible: true
        visible: false
    }

    MyPopUpWindow{
        id:myPopUpWindow
        visible: zeroLocationFailed  ? true :
                servoReady ? true :
                readLocationFailed ? true :
                readLocationOver ? true :
                forbidRun_NotFindZero ? true :
                forbidLeftRun ? true :
                forbidRightRun ? true :
                currentLocationEqualLocation ? true :
                notChooseMechine ? true :
                workingForbidImpact ? true :
                sawErrForbidImpact ? true :
                sawNotRunForbidOut ? true :
                currentSectionesWorked ? true :
                notImpactForbidOut ? true :
                currentLocationForbidOut ? true :
                // autoPrintRun ? true :
                setExtraShortLessCDLC ? true :
                sawInPlacesSignalErr ? true :
                locationZeroOver ? true :
                forbidRightMechineMove ? true :
                extraLongLocation ? true :
                changeSawMethod ? true :
                errCorrected ? true :
                forbid_45NB ? true :
                extraShortOrigin ? true :
                cleanBatteryWarning ? true :
                cleanBatteryDone ? true :
                q_TL_Err ? true :
                z_TL_Err ? true :
                h_TL_Err ? true :
                                     false




        // visible: !loginWindow.visible
        // opened: stationZeroFaild
    }

    InputPanel {
        id: inputPanel
        z: 99
        y: yPositionWhenHidden + 100
        x: 0
        width: parent.width

        property real yPositionWhenHidden: parent.height

        states: State {
            name: "visible"
            when: inputPanel.active
            PropertyChanges {
                target: inputPanel
                y: inputPanel.yPositionWhenHidden - inputPanel.height
            }
        }
        transitions: Transition {
            id: inputPanelTransition
            from: ""
            to: "visible"
            reversible: true
            // enabled: !VirtualKeyboardSettings.fullScreenMode
            ParallelAnimation {
                NumberAnimation {
                    properties: "y"
                    duration: 250
                    easing.type: Easing.InOutQuad
                }
            }
        }

    }


    BottomSwitch{       // 底部切换按钮
        id:bottomSwitch
        anchors.horizontalCenter: backGround.horizontalCenter
        anchors.bottom: backGround.bottom
        anchors.bottomMargin: 5
        visible: !loginWindow.visible
        onVisibleChanged: currentPage = 1
    }


}
